package dao;

import org.apache.ibatis.session.SqlSession;
import mapper.EmployeeMapper;
import model.Employee;
import utils.MyBatisUtils;

public class EmployeeDao {
	public Employee findWorkperson(String id) {
		SqlSession session=MyBatisUtils.getSqlSession();
		EmployeeMapper mapper=session.getMapper(EmployeeMapper.class);
		Employee obj=mapper.findWorkperson(id);
		session.close();
		return obj;
	}
	public Employee findDeliveryperson(String id) {
		SqlSession session=MyBatisUtils.getSqlSession();
		EmployeeMapper mapper=session.getMapper(EmployeeMapper.class);
		Employee obj=mapper.findDeliveryperson(id);
		session.close();
		return obj;
	}
	public void insertWorkperson(Employee obj) {
		SqlSession session=MyBatisUtils.getSqlSessionAutoCommit();
		EmployeeMapper mapper=session.getMapper(EmployeeMapper.class);
		mapper.insertWorkperson(obj);
		session.close();
	}
	
	public void updateWorkperson(Employee obj) {
		SqlSession session=MyBatisUtils.getSqlSessionAutoCommit();
		EmployeeMapper mapper=session.getMapper(EmployeeMapper.class);
		mapper.updateWorkperson(obj);
		session.close();
	}
	
	public void deleteWorkperson(String id) {
		SqlSession session=MyBatisUtils.getSqlSessionAutoCommit();
		EmployeeMapper mapper=session.getMapper(EmployeeMapper.class);
		mapper.deleteWorkperson(id);
		session.close();
	}
	public void insertDeliveryperson(Employee obj) {
		SqlSession session=MyBatisUtils.getSqlSessionAutoCommit();
		EmployeeMapper mapper=session.getMapper(EmployeeMapper.class);
		mapper.insertWorkperson(obj);
		session.close();
	}
	
	public void updateDeliveryperson(Employee obj) {
		SqlSession session=MyBatisUtils.getSqlSessionAutoCommit();
		EmployeeMapper mapper=session.getMapper(EmployeeMapper.class);
		mapper.updateWorkperson(obj);
		session.close();
	}
	
	public void deleteDeliveryperson(String id) {
		SqlSession session=MyBatisUtils.getSqlSessionAutoCommit();
		EmployeeMapper mapper=session.getMapper(EmployeeMapper.class);
		mapper.deleteWorkperson(id);
		session.close();
	}
}
